package cn.wolfcode.luowowo.search.service.impl;

import cn.wolfcode.luowowo.search.domain.FlightTemplate;
import cn.wolfcode.luowowo.search.query.FlightQueryObject;
import cn.wolfcode.luowowo.search.service.IFlightEsService;
import cn.wolfcode.luowowo.search.service.repository.FlightTemplateRepository;
import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;

@Service
public class FlightEsServiceImpl implements IFlightEsService {

    @Autowired
    private FlightTemplateRepository flightTemplateRepository;

    @Override
    public void save(FlightTemplate flightTemplate) {
        flightTemplateRepository.save(flightTemplate);
    }

    @Override
    public Page query(FlightQueryObject qo) {
        //分页参数对象
        PageRequest of = PageRequest.of(qo.getCurrentPage()-1, qo.getPageSize());
        return flightTemplateRepository.findAll(of);
    }
}
